package org.fig.ioc.bean.definition;

import org.fig.ioc.overview.domain.User;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @Description:
 * @Author: Flynn Vanderboom
 * @Data: 2021/6/15 20:34
 */

public class BeanInstantiationDemo {
    public static void main(String[] args) {
        BeanFactory beanFactory = new ClassPathXmlApplicationContext("classpath:/META-INF/bean-instantiation-context.xml");
        User user = beanFactory.getBean("user-by-static-method", User.class);
        System.out.println("静态工厂方法创建:"+user);
        User user2 = beanFactory.getBean("user-by-instance-method", User.class);
        System.out.println("工厂方法创建:"+user2);
        User user3 = beanFactory.getBean("user-by-factory-bean",User.class);
        System.out.println("FactoryBean创建:"+user3);
        
        System.out.println(user==user3);
    }
}
